﻿<%@ Page Language="C#" MasterPageFile="~/Web/Master/BackMasterPage.master" AutoEventWireup="true" CodeFile="BookTypeManage.aspx.cs" Inherits="Web.Back.BookTypeManager" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <form runat="server">
        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
            <h1 class="h2">图书分类信息</h1>
        </div>

        <!-- /.row -->
        <div class="panel panel-default">
            <!-- /.panel-heading -->
            <div class="panel-body">
                <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>分类名称</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="odd gradeX">
                            <td disable="true">-</td>
                            <td>
                                <asp:TextBox class="form-control" placeholder="分类名称" ID="TextTypeName" runat="server"></asp:TextBox></td>
                            <td>
                                <div class="text-center">
                                    <asp:Button class="btn btn-success" ID="BtnAddBook" runat="server" Text="添加" OnClick="BtnAddBookType_Click" /></div>
                            </td>
                        </tr>
                        <%=TypeList %>
                    </tbody>
                </table>
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.row -->
        </div>
           
        <!-- /#page-wrapper -->
        <!-- /#wrapper -->
        <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="text-danger">您确定要删除这个类别吗？该类别下的所有图书会被分类到“<code>其他</code>”中。</h3>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <asp:TextBox Style="display: none;" ID="BookTypeId" runat="server"></asp:TextBox>
                        <asp:Button class="btn btn-danger btn-ok" ID="BtnDeleteBook" runat="server" Text="删除" OnClick="BtnDeleteBookType_Click" />
                    </div>
                </div>
            </div>
        </div>
    </form>

    <script type="text/javascript">
        $(function () {
            $(".btn_delete").click(function () {
                console.log($(this).parent().attr("bookTypeId"));
                $(<%=BookTypeId.ClientID%>).val($(this).parent().attr("bookTypeId"));
            });
            $(".btn_update").click(function () {
                $(<%=BookTypeId.ClientID%>).val($(this).parent().attr("bookTypeId"));
                window.location.href = "UpdateBookInfo.aspx?bookId=" + $(this).parent().attr("bookId");
            });
        });
    </script>
</asp:Content>
